﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Admin_jiaju.Core.Models;
using Admin_jiaju.mvc.Models.Students;

namespace Admin_jiaju.mvc.Models
{
    public class ServiceProfile: Profile
    {
        public ServiceProfile()
        {
            CreateMap<Student, StudentViewModel>()
                .ForMember(dest => dest.StuClassName, opt => opt.MapFrom(src => src.StuClass.ClassName))
                .ReverseMap();
            CreateMap<Product, ProductView>()
               .ForMember(dest => dest.TypeName, opt => opt.MapFrom(src => src.ProductType.Name))
               .ReverseMap();
            CreateMap<ProductView, Product>();
            CreateMap<BannerView, Banner>();
            CreateMap<Banner, BannerView>();
            CreateMap<ProductType, ProductTypeView>();
            CreateMap<ProductTypeView, ProductType>();
            CreateMap<PicTrue, PicTrueView>()
                .ForMember(dest => dest.ProductName, opt => opt.MapFrom(src => src.Product.Name))
                .ReverseMap();
            CreateMap<PicTrueView, PicTrue>();
            CreateMap<News, NewsView>()
              .ForMember(dest => dest.NewTypeName, opt => opt.MapFrom(src => src.NewsType.Name));
            CreateMap<NewsView, News>();
            CreateMap<NewsType, NewTypeView>();
            CreateMap<NewTypeView, NewsType>();
            CreateMap<Designer, DesignerViewModel>();
            CreateMap<DesignerViewModel, Designer>();
            CreateMap<Message, MessageViewModel>();
            CreateMap<MessageViewModel, Message>();
        }
    }
}
